package com.test.dazuoye.controller;

import com.test.dazuoye.domain.shangjia;
import com.test.dazuoye.service.ShangJiaService;
import com.test.dazuoye.service.YongHuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @date 2020/6/6-21:59
 *
 * 保存，删除，查看全部商品，查看全部订单
 */

@Controller
@RequestMapping("/shangjia")
public class ShangJiaController {

    @Autowired
    private ShangJiaService shangJiaService;

    //
    @RequestMapping("/saveShangpin")
    public @ResponseBody String saveShangPin(shangjia shangjia) {
        System.out.println(shangjia);
        shangJiaService.saveShangJia(shangjia);
        return "shangjia";
    }

    @RequestMapping("/deleteShangpin")
    public @ResponseBody void deleteShangPin(String cname) {
        shangJiaService.deleteShangJia(cname);
    }

    @RequestMapping("/findShangpin")
    public @ResponseBody List<shangjia> findShangPin() {
        List<shangjia> all = shangJiaService.findAll();
        for (shangjia a:all){
            System.out.println(a);
        }
        return all;
    }



}
